/**
 * Copyright 2018 orivil.com. All rights reserved.
 * Use of this source code is governed by a MIT-style
 * license that can be found at https://mit-license.org.
 */

package code

import (
	"gitee.com/tugoer/swagger"
	"net/http"
	"gitee.com/tugoer/examples/projects/param/code"
)

var FormHandler = func(postUrl string) http.HandlerFunc {
	// 设置请求参数
	op := &swagger.Operation{
		Summary: "提交表单",
		Description: "测试参数验证器",
	}
	op.AddParameters(code.Parameters)

	// 设置响应
	op.Responses = swagger.Responses{
		"200": {
			Description: "success",
			Schema:&swagger.Schema{
				Example: map[string]interface{}{
					"user": code.User{},
					"secure": code.Secure{},
				},
			},
		},
		"400": {Description: http.StatusText(http.StatusBadRequest)},
	}

	swagger.API2.AddOperation(http.MethodPost, postUrl, op)
	return code.FormHandler
}